package com.taxi.driver.module.main.mine.wallet.withdrawalrecord.withdrawldetails;

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.TextView;

import com.taxi.driver.R;
import com.taxi.driver.common.Application;
import com.taxi.driver.common.BaseActivity;
import com.taxi.driver.module.main.mine.wallet.withdrawalrecord.withdrawldetails.dagger.DaggerWithdrawDetailsComponent;
import com.taxi.driver.module.main.mine.wallet.withdrawalrecord.withdrawldetails.dagger.WithdrawDetailsModule;
import com.taxi.driver.module.vo.WithdrawDetailVO;
import com.taxi.driver.util.TimeUtils;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;

public class WithdrawDetailsActivity extends BaseActivity implements WithdrawDetailsContract.View {
    @BindView(R.id.tv_withdraw_fee)
    TextView mTvWithDrawFee;
    @BindView(R.id.tv_withdraw_way)
    TextView mTvWithDrawWay;
    @BindView(R.id.tv_withdraw_account_name)
    TextView mTvWithdrawAccountName;
    @BindView(R.id.tv_withdraw_account)
    TextView mTvWithdrawAccount;
    @BindView(R.id.tv_poundage)
    TextView mTvPoundage;
    @BindView(R.id.tv_apply_time)
    TextView mTvApplyTime;
    @BindView(R.id.tv_audit_time)
    TextView mTvAuditTime;
    @BindView(R.id.tv_audit_result)
    TextView mTvAuditResult;
    @BindView(R.id.tv_remark)
    TextView mTvRemark;

    @Inject
    WithdrawDetailsPresenter mPresenter;
    String cashUuid;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_withdraw_details);
        ButterKnife.bind(this);

        DaggerWithdrawDetailsComponent.builder()
                .appComponent(Application.getAppComponent())
                .withdrawDetailsModule(new WithdrawDetailsModule(this))
                .build().inject(this);

        cashUuid = getIntent().getStringExtra("cashUuid");
        mPresenter.reqWithdrawalDetails(cashUuid);
    }

    @Override
    public boolean isActive() {
        return false;
    }

    @Override
    public void showWithdrawalDetails(WithdrawDetailVO vo) {
        mTvWithDrawFee.setText(getString(R.string.withdraw_fee, vo.withdrawalFee + ""));
        if (vo.withrawalWay == 1) {
            mTvWithDrawWay.setText(getResources().getString(R.string.withdrawal_to_card));
            mTvPoundage.setText(getString(R.string.yuan, vo.poundage + ""));
        } else if (vo.withrawalWay == 2) {
            mTvWithDrawWay.setText(getResources().getString(R.string.withdrawal_to_weixin));
            mTvPoundage.setText(getString(R.string.yuan, vo.poundage + ""));
        } else if (vo.withrawalWay == 3) {
            mTvWithDrawWay.setText(getResources().getString(R.string.withdrawal_to_zhifubao));
            mTvPoundage.setText(getString(R.string.yuan, vo.poundage + ""));
        }
        mTvWithdrawAccountName.setText(vo.withdrawalAccountName);
        mTvWithdrawAccount.setText(vo.withdrawalAccount);
        mTvApplyTime.setText(TimeUtils.paseDateAndTime(vo.applyTime));
        mTvAuditTime.setText(vo.auditTime == 0 ? "" : TimeUtils.paseDateAndTime(vo.auditTime));
        if (vo.auditResult == 1) {
            mTvAuditResult.setText(getResources().getString(R.string.in_review));
        } else if (vo.auditResult == 2) {
            mTvAuditResult.setText(getResources().getString(R.string.withdrawal_success));
        } else if (vo.auditResult == 3) {
            mTvAuditResult.setText(getResources().getString(R.string.withdrawal_failure));
        }
        mTvRemark.setText(TextUtils.isEmpty(vo.remark) ? getString(R.string.none) : vo.remark);
    }
}
